//
//  FourSetModel.m
//  marrymarry
//
//  Created by lsj on 16/10/11.
//  Copyright © 2016年 cf. All rights reserved.
//

#import "FourSetModel.h"

@implementation FourSetModel
-(NSMutableArray * )getBackWithDataArry:(NSMutableArray *)dataArry
{
    NSMutableArray * myArry = [NSMutableArray new];
    for (NSDictionary * dic in dataArry) {
        NSDictionary * FromUserDic = [NSDictionary new];
        if (self.isMyheart) {
             FromUserDic = dic[@"user"];
        }else{
        FromUserDic = dic[@"fromUser"];
        }
        FourSetModel * model = [FourSetModel new];
        model.nameStr = FromUserDic[NICHEN_KEY];
        if ([[Tools getValueWithBirth:FromUserDic[BIRTH_TIME_KEY]] isEqualToString:@"0"]) {
            model.birthStr =@"1岁";
        }else{
            model.birthStr = [NSString stringWithFormat:@"%@岁",[Tools getValueWithBirth:FromUserDic[BIRTH_TIME_KEY]]];
        }
        model.headImgName = FromUserDic[HEADPHOTO];
        model.addressStr =[NSString stringWithFormat:@"工作生活：%@",[Tools getValueWithAddress:FromUserDic[WORK_PLACE_KEY]]];
        model.wantMarryTimeStr = [NSString stringWithFormat:@"期望：%@结婚",FromUserDic[WANT_MARRY_TIME_KEY]];
        model.TimeStr = [self timeWithTimeIntervalString:[NSString stringWithFormat:@"%@",dic[@"sendTime"]]];
        [myArry addObject:model];
    }
    
    return myArry;

}



- (NSString *)timeWithTimeIntervalString:(NSString *)timeString
{
//    NSTimeInterval time=[timeString doubleValue]+28800;//因为时差问题要加8小时 == 28800 sec
//    NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time];
//    NSLog(@"date:%@",[detaildate description]);
//    //实例化一个NSDateFormatter对象
//    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//    //设定时间格式,这里可以设置成自己需要的格式
//    [dateFormatter setDateFormat:@"yyyy.MM.dd HH:mm:ss"];
//    
//    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
  
        // 格式化时间
        NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
        formatter.timeZone = [NSTimeZone timeZoneWithName:@"shanghai"];
        [formatter setDateStyle:NSDateFormatterMediumStyle];
        [formatter setTimeStyle:NSDateFormatterShortStyle];
        [formatter setDateFormat:@"yyyy.MM.dd. HH:mm:ss"];
        
        // 毫秒值转化为秒
        NSDate* date = [NSDate dateWithTimeIntervalSince1970:[timeString doubleValue]/1000.0];
        NSString* dateString = [formatter stringFromDate:date];
    
    
    
    return dateString;
}

@end
